<html>
<head>
<title>LicznikDanegoKoloru.java</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.ln { color: rgb(0,0,0); font-weight: normal; font-style: normal; }
.s0 { color: rgb(0,0,128); font-weight: bold; }
.s1 { }
.s2 { color: rgb(128,128,128); font-style: italic; }
.s3 { color: rgb(0,0,255); }
</style>
</head>
<BODY BGCOLOR="#ffffff">
<TABLE CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#C0C0C0" >
<TR><TD><CENTER>
<FONT FACE="Arial, Helvetica" COLOR="#000000">
LicznikDanegoKoloru.java</FONT>
</center></TD></TR></TABLE>
<pre>

<a name="l1"><span class="s0">package </span><span class="s1">zadanie3; 
<a name="l2"> 
<a name="l3"></span><span class="s2">/** 
<a name="l4"> * Author: Daniel Michalski 
<a name="l5"> * Date: 28.02.13 
<a name="l6"> */</span><span class="s1"> 
<a name="l7"> 
<a name="l8"></span><span class="s0">public class </span><span class="s1">LicznikDanegoKoloru { 
<a name="l9">     </span><span class="s0">private int</span><span class="s1">[][][] obraz; 
<a name="l10"> 
<a name="l11">   </span><span class="s0">public </span><span class="s1">LicznikDanegoKoloru(</span><span class="s0">int</span><span class="s1">[][][] obraz) { 
<a name="l12">       </span><span class="s0">this</span><span class="s1">.obraz = obraz; 
<a name="l13">   } 
<a name="l14"> 
<a name="l15">   </span><span class="s0">public int </span><span class="s1">IloscPikseliSzarych(){ 
<a name="l16">       </span><span class="s0">int </span><span class="s1">wielkoscX = obraz.length; 
<a name="l17">       </span><span class="s0">int </span><span class="s1">wielkoscY = obraz[</span><span class="s3">0</span><span class="s1">].length; 
<a name="l18">       </span><span class="s0">int </span><span class="s1">licznikPixeliSzarych = </span><span class="s3">0</span><span class="s1">; 
<a name="l19"> 
<a name="l20">       </span><span class="s0">for </span><span class="s1">(</span><span class="s0">int </span><span class="s1">i = </span><span class="s3">0</span><span class="s1">; i &lt; wielkoscX; i++) { 
<a name="l21">           </span><span class="s0">for </span><span class="s1">(</span><span class="s0">int </span><span class="s1">j = </span><span class="s3">0</span><span class="s1">; j &lt; wielkoscY ; j++) { 
<a name="l22">                </span><span class="s0">if</span><span class="s1">(obraz[i][j][</span><span class="s3">0</span><span class="s1">] != </span><span class="s3">0 </span><span class="s1">&amp;&amp; obraz[i][j][</span><span class="s3">0</span><span class="s1">] != </span><span class="s3">255</span><span class="s1">) 
<a name="l23">                    </span><span class="s0">if</span><span class="s1">(obraz[i][j][</span><span class="s3">0</span><span class="s1">] == obraz[i][j][</span><span class="s3">1</span><span class="s1">] &amp;&amp; obraz[i][j][</span><span class="s3">1</span><span class="s1">] == obraz[i][j][</span><span class="s3">2</span><span class="s1">]) 
<a name="l24">                        licznikPixeliSzarych++; 
<a name="l25">           } 
<a name="l26">       } 
<a name="l27"> 
<a name="l28">       </span><span class="s0">return </span><span class="s1">licznikPixeliSzarych; 
<a name="l29">   } 
<a name="l30"> 
<a name="l31">    </span><span class="s0">public int </span><span class="s1">IloscPikseliCzerwonych(){ 
<a name="l32">        </span><span class="s0">int </span><span class="s1">wielkoscX = obraz.length; 
<a name="l33">        </span><span class="s0">int </span><span class="s1">wielkoscY = obraz[</span><span class="s3">0</span><span class="s1">].length; 
<a name="l34">        </span><span class="s0">int </span><span class="s1">licznikPixeliCzerwonych = </span><span class="s3">0</span><span class="s1">; 
<a name="l35"> 
<a name="l36">        </span><span class="s0">for </span><span class="s1">(</span><span class="s0">int </span><span class="s1">i = </span><span class="s3">0</span><span class="s1">; i &lt; wielkoscX; i++) { 
<a name="l37">            </span><span class="s0">for </span><span class="s1">(</span><span class="s0">int </span><span class="s1">j = </span><span class="s3">0</span><span class="s1">; j &lt; wielkoscY ; j++) { 
<a name="l38">                </span><span class="s0">if</span><span class="s1">(obraz[i][j][</span><span class="s3">0</span><span class="s1">] == </span><span class="s3">255</span><span class="s1">) 
<a name="l39">                    </span><span class="s0">if</span><span class="s1">(obraz[i][j][</span><span class="s3">1</span><span class="s1">]==</span><span class="s3">0 </span><span class="s1">&amp;&amp; obraz[i][j][</span><span class="s3">1</span><span class="s1">] == obraz[i][j][</span><span class="s3">2</span><span class="s1">] ) 
<a name="l40">                        licznikPixeliCzerwonych++; 
<a name="l41">            } 
<a name="l42">        } 
<a name="l43"> 
<a name="l44">        </span><span class="s0">return </span><span class="s1">licznikPixeliCzerwonych; 
<a name="l45">    } 
<a name="l46"> 
<a name="l47">} 
<a name="l48"> 
<a name="l49"></span></pre>
</body>
</html>